import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../../resource/language/generated/l10n.dart';
import '../../interface/root_proxy_model.dart';
import 'doufeng_time_check_widget_model.dart';

class DoufengTimeCheckWidget extends StatelessWidget {
  const DoufengTimeCheckWidget({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProxyProvider<RootProxyModel,
            DoufengTimeCheckWidgetModel>(
          create: (createcontext) => DoufengTimeCheckWidgetModel(context),
          update: (context, rootProxyModel, leafModel) {
            if (leafModel == null) throw ArgumentError.notNull('leafModel');
            leafModel.roomModel = rootProxyModel;
            return leafModel;
          },
        ),
      ],
      child: Consumer<DoufengTimeCheckWidgetModel>(
        builder: (context, model, child) {
          return Align(
            alignment: Alignment.topCenter,
            child: Container(
              height: 22,
              decoration: BoxDecoration(
                color: const Color(0x1EDFD6FF),
                borderRadius: BorderRadius.circular(16),
              ),
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  const SizedBox(
                    width: 9,
                  ),
                  Image.asset(
                    "assets/images/ic_doufeng_time.png",
                    width: 14,
                    height: 14,
                    fit: BoxFit.fill,
                  ),
                  const SizedBox(
                    width: 5,
                  ),
                  Text(
                    model.textTimeLast,
                    style: const TextStyle(
                      fontSize: 11,
                      color: Colors.white,
                      fontWeight: FontWeight.w400,
                      height: 1,
                    ),
                  ),
                  const SizedBox(
                    width: 8,
                  ),
                  continuanceWidget(context, model),
                ],
              ),
            ),
          );
        },
      ),
    );
  }

  /// 1.如果是体验兜风车主、GS 都不显示续时按钮
  /// 2.其它类型的兜风只有车主才显示续时按钮
  Widget continuanceWidget(
      BuildContext context, DoufengTimeCheckWidgetModel conModel) {
    /// prtType 1或者 2是体验兜风
    ///
    return Container();
    // if (conModel.roomModel.doufengType == 3) {
    //   // if (UserManager.instance.currentUser?.job == Job.BOSS) {
    //   return CupertinoButton(
    //     minSize: 0,
    //     padding: EdgeInsets.zero,
    //     onPressed: () {
    //       conModel.renew(context);
    //     },
    //     child: Container(
    //       width: 45,
    //       height: 22,
    //       alignment: Alignment.center,
    //       decoration: BoxDecoration(
    //         color: const Color(0xFFFFD400),
    //         borderRadius: BorderRadius.circular(12),
    //       ),
    //       child: Text(
    //         T.current.continued_time,
    //         style: const TextStyle(
    //           fontSize: 13,
    //           color: Color(0xff333333),
    //           fontWeight: FontWeight.w400,
    //           height: 1,
    //         ),
    //       ),
    //     ),
    //   );
    //   // } else {
    //   //   return const SizedBox.shrink();
    //   // }
    // } else {
    //   return const SizedBox.shrink();
    // }
  }
}
